Passed
Push — master ( d2bce4...71830f )
by Dmytro
130:29 queued 126:43
created

API   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 17
c 0
b 0
f 0
rs 10
1
import sinon from 'sinon';
2
import { getNamespace } from 'cls-hooked';
3
import { apiLogger } from '../logger';
4
import { load } from '../utils';
5
6
const ATLASSIAN_API = load('AtlassianApi').default;
7
8
class API extends ATLASSIAN_API {
9
    async getMyself() {
10
        return {
11
            id    : 1,
12
            email : this.auth.username,
13
            name  : 'Tyler Simpson'
14
        };
15
    }
16
17
    getTraceId() {
18
        return getNamespace('__TEST__').get('current').id;
19
    }
20
21
    initLogger() {
22
        this.logger = apiLogger;
23
    }
24
}
25
26
const methods = Object.getOwnPropertyNames(API.prototype).filter(m => m !== 'constructor');
27
28
methods.forEach(methodName => {
29
    sinon.replace(ATLASSIAN_API.prototype, methodName, API.prototype[methodName]);
30
});
31